<template>
	<view class="myWallet">
		<navBar  title="我的钱包" color="#333" background="#fff"></navBar>
		<view class="top">
			<image :src="`${baseImg}/static/adminShop/cardBg.png`" mode=""></image>
			<view class="info">
				<view class="title">可提现（元）<span @click="toViewWallet">查看明细</span></view>
				<view class="okPrice">{{Number(priceInfo.cashout_amount).toFixed(2)}}</view>
				<view class="btn">
					<button type="default" @click="toWithdCom">提现</button>
				</view>
			</view>
		</view>
		<view class="num">
			<!-- <view class="item" @click="toWaitPut">
				待结算
				<view class="right">{{Number(priceInfo.wait_settlement_amount).toFixed(2)}}<span class="iconfont icon-jinru"></span></view>
			</view> -->
			<view class="item" @click="toPutOk">
				已提现（元）
				<view class="right">{{Number(priceInfo.withdrawn_amount).toFixed(2)}}<span class="iconfont icon-jinru"></span></view>
			</view>
			<view class="item" @click="toFreeMoney">
				冻结金
				<view class="right">{{Number(priceInfo.freeze_amount).toFixed(2)}}<span class="iconfont icon-jinru"></span></view>
			</view>
		</view>
	</view>
</template>

<script>
	import Https from '@/service/verification.js';
	export default{
		data(){
			return{
				baseImg:this.$static,
				priceInfo:{}
			}
		},
		created() {
			this.getPriceInfo()
		},
		methods:{
			// 进入提现页面
			toWithdCom(){
				// uni.navigateTo({
				// 	url:`/pagesOne/distri/withdCom/withdCom?level=${0}&allCanPrice=${this.priceInfo.cashout_amount}`
				// })
				this.getAccountInfo()
			},
			// 查询云商通账户信息
			getAccountInfo() {
				var that = this;
				let params = {};
				// let identityType = uni.getStorageSync('identityType'); //1企业,2个人
				// let isMaster = uni.getStorageSync('isMaster'); //1老板,0员工
				// console.log(identityType);
				Https.GetAccountMes(params).then(res => {
					if (res.code == 1) {
						console.log(res.data);
						var data = res.data;
						if (data.is_realname == 0) {
							uni.showModal({
								title: '提示',
								content: '暂时还没实名验证,是否实名验证?',
								confirmText: '确定',
								success: function(res) {
									if (res.confirm) {
										// 会员类型(2企业会员,3个人会员)
										if (data.member_type == 2) {
											console.log(123);
											uni.navigateTo({
												url: '/pages_Verification/verification/select/certificate'
											});
											return;
										}
										if (data.member_type == 3) {
											console.log(456);
											uni.navigateTo({
												url: '/pages_Verification/verification/personal/personal'
											});
											return;
										}
									}
								}
							});
							return;
						}
						if (data.is_realname == 1) {
							if (data.is_phone == 0) {
								uni.showModal({
									title: '提示',
									content: '暂时还没绑定手机号,是否绑定?',
									confirmText: '确定',
									success: function(res) {
										if (res.confirm) {
											uni.navigateTo({
												url: '/pages_Verification/verification/bindPhone/BindPhone'
											});
										}
									}
								});
							} else if (data.is_sign == 0) {
								uni.showModal({
									title: '提示',
									content: '需要完善支付信息,是否继续?',
									confirmText: '确定',
									success: function(res) {
										if (res.confirm) {
											uni.navigateToMiniProgram({
												appId: 'wxc46c6d2eed27ca0a', //通商云平台账户小程序appId
												path: 'pages/merchantAddress/merchantAddress',
												extraData: {
													// 测试环境地址：url=https://test.allinpay.com/yungateway/member/signContract.html?
													// 生产环境地址：url=https://fintech.allinpay.com/yungateway/member/signContract.html?
													// targetUrl: 'https://test.allinpay.com/yungateway/member/signContract.html?' + data.signContract.data.param //商户拼接的请求报文
													targetUrl: data.signContract
												},
												envVersion: 'release', //develop 开发版  trial 体验版  release 正式版
												success(res) {
													// 打开成功
													console.log(res);
												}
											});
										}
									}
								});
								// let url = encodeURIComponent('https://test.allinpay.com/yungateway/member/signContract.html?' + data.signContract.data.param);
								// uni.navigateTo({
								// 	url: '/pagesOne/verification/webview?url=' + url
								// });
							} else if (data.is_phone == 1 && data.is_sign == 1) {
								// if (data.member_type == 3) {
								// 	// 个人
								// 	uni.navigateTo({
								// 		url: '/pages_Verification/verification/bankCard/bankCardList?memberType=3'
								// 	});
								// } else if (data.member_type == 2) {
								// 	// 企业
								// 	uni.navigateTo({
								// 		url: '/pages_Verification/verification/bankCard/bankCardList?memberType=2'
								// 	});
								// }
								uni.navigateTo({
									url:`/pagesOne/distri/withdCom/withdCom?level=${0}&allCanPrice=${this.priceInfo.cashout_amount}`
								})
							}
							return;
						}
						if (data.is_realname == 2) {
							if (data.member_type == 3) {
								// 个人
								uni.navigateTo({
									url: '/pages_Verification/verification/status/status?isPersonal=true&status=0&isIndex=true'
								});
							} else if (data.member_type == 2) {
								// 企业
								uni.navigateTo({
									url: '/pages_Verification/verification/status/status?isPersonal=false&status=0&isIndex=true'
								});
							}
							return;
						}
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
				});
			},
			// 查看明细
			toViewWallet(){
				uni.navigateTo({
					url:'/pagesFour/home/myWallet/viewWallet?canPutPrice='+this.priceInfo.cashout_amount
				})
			},
			// 进入待结算明细
			toWaitPut(){
				uni.navigateTo({
					url:'/pagesFour/home/myWallet/waitPut?waitPrice='+this.priceInfo.wait_settlement_amount
				})
			},
			
			// 进入已结算
			toPutOk(){
				uni.navigateTo({
					url:'/pagesFour/home/myWallet/putOk?okPrice='+this.priceInfo.withdrawn_amount + '&level=' + 1
				})
			},
			
			// 进入冻结金
			toFreeMoney(){
				uni.navigateTo({
					url:'/pagesFour/home/myWallet/freeMoney?freeMoney='+this.priceInfo.freeze_amount
				})
			},
			
			// 获取钱包信息
			getPriceInfo(){
				this.$api.getPriceInfo({level:0}).then(res=>{
					console.log(res,'钱包信息')
					if(res.code==1){
						this.priceInfo = res.data?res.data:{}
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.myWallet{
		.top{
			position: relative;
			width: 702rpx;
			height: 392rpx;
			margin: 40rpx auto 24rpx ;
			image{
				width: 100%;
				height: 100%;
				position: absolute;
				left: 0;
				top: 0;
			}
			.info{
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				width: 100%;
				height: 100%;
				position: absolute;
				top: 0;
				left: 0;
				color: #fff;
				padding: 60rpx 32rpx 48rpx;
				.title{
					display: flex;
					align-items: center;
					justify-content: space-between;
					font:400 28rpx/48rpx PingFang SC;
					span{
						padding: 0 20rpx;
						font: 400 26rpx/40rpx PingFang SC;
						color: #DBA954;
						border: 2rpx solid #DBA954;
						border-radius: 44rpx;
					}
				}
				.okPrice{
					font: 600 60rpx/40rpx PingFang SC;
				}
				.btn{
					button{
						margin: 0 auto;
						width: 638rpx;
						height: 88rpx;
						background-color: #DBA954;
						border-radius: 46rpx;
						font: 500 32rpx/88rpx PingFang SC;
						color: #fff;
					}
				}
			}
		}
		.num{
			width: 702rpx;
			margin: 0 auto;
			background-color: #fff;
			border-radius: 8rpx;
			.item{
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 40rpx 28rpx 40rpx 40rpx;
				font: 500 32rpx/32rpx PingFang SC;
				color: #0A0605;
				.right{
					display: flex;
					justify-content: space-between;
					align-items: center;
					color: #DBA954;
					.iconfont{
						font-size: 24rpx;
						color: #D8D8D8;
						margin-left: 10rpx;
					}
				}
			}
		}
	}
</style>